package com.yy.tech.data.app.service.impl;

import com.yy.tech.data.app.domain.Employee;
import com.yy.tech.data.app.domain.ExampleRequest;
import com.yy.tech.data.app.domain.ExampleResponse;
import com.yy.tech.data.app.service.ExampleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

@Service
public class ExampleServiceImpl implements ExampleService {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Override
    public ExampleResponse doHandle(ExampleRequest request) {
        ExampleResponse response = new ExampleResponse();
        response.setEmployee(request.getEmployee());
        logger.info("doHandle bean {}",request);
        return response;
    }

    @Override
    public Map<String, Object> doHandle(Map<String, Object> request) {
        request.put("employeeId",UUID.randomUUID().getMostSignificantBits());
        request.put("idNumber","310122199907121234");
        request.put("updateTime",new Date());
        logger.info("doHandle map {}",request);
        return request;
    }

    @Override
    public ExampleResponse doHandle(String idNumber) {
        logger.info("do handle param {}",idNumber);

        ExampleResponse response = new ExampleResponse();
        Employee employee= new Employee();
        employee.setEmployeeId(UUID.randomUUID().getMostSignificantBits());
        employee.setEmail("example@163.com");
        employee.setBirthdate(LocalDate.of(1999,3,12));
        employee.setUpdateTime(new Date());
        employee.setIdNumber(idNumber);
        employee.setIdType("SFZ");
        employee.setName("Example path variable");
        employee.setPhone("18817881788");
        response.setEmployee(employee);
//        employee.set
        logger.info("do handle param {}",employee);
        return response;
    }


}
